<?php

namespace common\widgets;

use Yii;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\InputWidget;
use common\assets\metronic\MetronicSelectSplitterAsset;

/**
 * AddressInput
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class SelectSplitterInput extends InputWidget {

    /**
     * @inheritdoc
     */
    public function run() {
        $this->registerAssets();
        echo Html::dropDownList('address', null, [
            '请选择',
            'Category 1' => [
                1 => 'Option 1',
                2 => 'Option 2',
                3 => 'Option 3',
                4 => 'Option 4',
                5 => 'Option 5',
            ],
            'Category 2' => [
                21 => 'Option 21',
                22 => 'Option 22',
                23 => 'Option 23',
                24 => 'Option 24',
                25 => 'Option 25',
            ]
        ], [
            'id' => $this->options['id'],
            'size' => 1,
            'class' => "form-control",
            'prompt' => ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']]
        ]);
    }

    /**
     * Renders the date picker widget.
     */
    protected function renderInput() {
        
    }

    /**
     * Registers the needed assets
     */
    public function registerAssets() {
        $view = $this->getView();
        MetronicSelectSplitterAsset::register($view);
        $scripts = 'jQuery("#' . $this->options['id'] . '").selectsplitter({selectSize: 1});';
        $view->registerJs($scripts);
    }

}
